@include('Home.head')
<style>
    .am-header{
        background: linear-gradient(180deg,#d2393b 0%, #ab191a 100%);
    }
    .title{
        color: #ffffff;
    }
</style>
<link rel="stylesheet" href="{{ URL::asset('js/swiper3/css/swiper.min.css') }}"/>
<script src="{{ URL::asset('js/swiper3/js/swiper.min.js') }}"></script>
<body>
<div class="container" id="app">
    <header data-am-widget="header" class="am-header am-header-default" style="background-color: #000000;">
        <div class="am-header-left am-header-nav">
            <a  onclick="javascript:history.back(-1);" class="">
                <i class="am-header-icon am-icon-chevron-left"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="#title-link" class="" style="font-weight: 600;">推客产品详情</a>
        </h1>
    </header>
    <div>
        <div class="swiper-container">
            <div class="swiper-wrapper">
                <div v-for="(item,index) in data.goodsCarouselPictures" class="swiper-slide">
                        <img :src="item" mode="widthFix" class="item-image" />
                </div>
            </div>
            <div class="swiper-pagination"></div>

        </div>
        <div class="goods-price">
            <div class="price">
                &yen;@{{data.price}}
            </div>
            <div class="market-price">
                &yen;@{{data.marketPrice}}
            </div>
            <div class="sale">
                @{{data.sales_tip}}购买
            </div>
        </div>
        <div class="goods-title">
            @{{data.goodsName}}
        </div>
        <div class="goods-detail">
            <image v-for="(item,index) in data.goodsDetailPictures" :src="item" mode="widthFix" class="item-image"></image>
        </div>
        <div class="buy" @click="buy">立即购买</div>
    </div>
</div>
<script>
    var app = new Vue({

        el:"#app",

        data: {
            data:[],
            list:[],
            source:'pdd',
            goodsId:'',
            page:1,
            Height:500
        },

        //事件

        methods: {

            initialize:function () {
                this.source = this.obtain('source');
                this.goodsId  = this.obtain('goodsId');

            },
            getData(){

                var _this=this;
                $.post("/home/index/tuike_det_data",{'_token':'{{csrf_token()}}',"goodsId":_this.goodsId,"source":_this.source},function (res) {

                    if(res.code == 0){
                        _this.data=res.data;

                    } else {
                        layer.msg(res.data,{icon:7});
                    }

                },"JSON");


            },
            //获取url id
            obtain:function (val) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i=0;i<vars.length;i++) {
                    var pair = vars[i].split("=");
                    if(pair[0] == val){
                        return pair[1];
                    }
                }
            },

            buy(e){
                var _this = this;

                if(_this.source=='pdd' || _this.source=='jd'){
                    window.location.href=_this.data.url;
                }else if(_this.source=='taobao'){
                    window.location.href=_this.data.short_click_url;

                }else {
                   if(copyText(_this.data.tkl)){
                       layer.msg("请打开抖音APP或小程序进行购买",{icon:1});
                   }

                }










            },


        },

        //自动执行

        mounted: function () {
            this.initialize();

            this.getData();

        },

    });


    var swiper = new Swiper(".swiper-container", {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: 2500,
        autoplayDisableOnInteraction: false
    });


    function copyText(value) {
        if (value == null || value === '') return false
        var textarea = document.createElement('textarea')
        textarea.value = value
        document.body.appendChild(textarea)
        textarea.focus()
        textarea.setSelectionRange ? textarea.setSelectionRange(0, textarea.value.length) : textarea.select()
        var result = document.execCommand('copy')
        document.body.removeChild(textarea)
        return result
    }

</script>
<style>

    .swiper-container {
        width: 100%;
        height: 100%;
    }
    .swiper-slide {
        text-align: center;
        font-size: 18px;
        background: #fff;

        /* Center slide text vertically */
        display: -webkit-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
    }

    .swiper-slide img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }


    .banner{
        width: 100%;
        height: 750rpx;
    }
    .banner>swiper{
        width: 100%;
        height: 750rpx;
    }
    .banner-img{
        width: 100%;
        height: 750rpx;
    }
    .banner-img image{
        width: 100%;
    }
    .buy{
        width: 80%;
        background-color: crimson;
        color: #fff;
        text-align: center;
        border-radius: 20px;
        height: 40px;
        position: fixed;
        bottom: 10px;
        left: 10%;
        line-height: 40px;
    }
    .goods-title{
        width: 90%;
        padding: 10px 5%;
        font-size: 16px;
        font-weight: bold;
        color: #333333;
        line-height: 30px;
    }
    .goods-price{
        width: 90%;
        padding: 5px 5%;
        display: flex;
        height: 40px;
    }
    .price{
        font-size: 16px;
        color: crimson;
        font-weight: bold;
        line-height: 40px;
    }
    .market-price{
        color: #666666;
        font-size: 14px;
        text-decoration: line-through;
        line-height: 45px;
        flex: 1;
    }
    .sale{
        color: #666666;
        font-size: 14px;
        line-height: 45px;
    }
    .goods-detail{
        padding: 0 5%;
        font-size: 0;
    }
    .goods-detail image{
        width: 100%;
    }
    .item-image{
        width: 100%;
        max-width: 640px;
    }
</style>

</body>
</html>